import requests
from util.time_stamp import get_time_stamp
import execjs
import hashlib

with open("./parse/2.福建公共交易平台.js") as f:
    js_str = f.read()
    js_code = execjs.compile(js_str, cwd="./parse")




page = 1

e = {
    "ts": get_time_stamp(),
    "pageNo": page,
    "pageSize": 20,
    "total": 3413,
    "KIND": "GCJS",
    "GGTYPE": "1",
    "timeType": "6",
    "BeginTime": "2025-05-20 00:00:00",
    "EndTime": "2025-11-20 23:59:59"
}


n = js_code.call("d", e)
sign = hashlib.md5(n.encode()).hexdigest()
print(sign)

e.update({
    "AREACODE": "",
    "M_PROJECT_TYPE": "",
    "PROTYPE": "",
    "createTime": "",
})



res = requests.post('https://ggzyfw.fj.gov.cn/FwPortalApi/Trade/TradeInfo', json=e, headers={
    'portal-sign': sign,
})

print(res.json()['Data'])

r = js_code.call("b", res.json()['Data'])
print(r)





# JS 逆向
# 请求参数逆向portal-sign（md5）    解析数据逆向Data（AES）







